<extend name="Public/base" />

<block name="body">
    <div class="main-title" style="padding-bottom: 10px;">
        <h2>{$title}</h2>
    </div>
    <div class="row ng-cloak" ng-controller="SubproCtrl" ng-init="init()">
        <form action="{:U('subproapplyadd')}" method='post' class="form-horizontal" >
            <div class="" style="margin-left: 20px;">
                <div class="controls"><span class="btn btn-primary" ng-click="moreItem();">添加商品+</span></div>
            </div>
            <div class="col-md-12">
                <div class="panel panel-default">
                    <div class="panel-body" style="padding-bottom: 0px;padding-top: 0px;">
                        <div style="border: #000 1px solid;margin-top: 5px;margin-bottom: 5px;" class='data-table table-striped '>
                            <table  id="tbodyspec">
                                <thead>
                                    <tr>
                                        <th scope="col" width="20%">商品名称</th>
                                        <th scope="col" width="10%">商品编码</th>
                                        <th style="width:100px;">单位</th>
                                        <th style="width:100px;">单价</th>
                                        <th style="padding-left: 50px;">数量</th>
                                        <th>总价</th>
                                        <th>操作</th>
                                    </tr>
                                </thead>
                                <tbody id="tbodyspec_a">
                                    <tr ng-repeat="item in items">
                                        <td class="change">
                                            <select select2 style="height: 30px; width:180px;" ng-change="productSelect($index,x)" ng-model="x">
                                                <option value="">请选择...</option>
                                                <option ng-repeat="product in productList" value="{{($index)}}" >{{product.pname}}({{product.spec}})</option>
                                            </select>
                                        </td>
                                        <td>
                                            <span name="BIN" ng-bind="item.product.id" ></span>
                                        </td>
                                        <td>
                                            <span>{{item.product.mother_to_son}}{{item.product.son_unit}}/{{item.product.mother_unit}}</span>
                                        </td>
                                        <td>
                                            <span name="BIN">{{item.product.unitprice}}元/{{item.product.son_unit}}</span>
                                        </td>
                                        <td class="row" style="padding: 0">
                                            <div class="col-lg-3" style="padding: 0;margin: 0">
                                                <div class="input-group ">
                                                    <input type="tel" style="" class="form-control input-x" ng-change="cnt($index)" ng-model="item.mother_unit_cnt" />
                                                    <span class="input-group-addon" ng-bind="item.product.mother_unit"></span>
                                                </div>
                                            </div>
                                            <span style="margin: 0" class="col-lg-1">或</span>
                                            <div class="col-lg-3" style="padding: 0;margin: 0">
                                                <div class="input-group " >
                                                    <input type="tel" style="" class="form-control input-x" ng-change="cnt($index)" ng-model="item.son_unit_cnt" />
                                                    <span class="input-group-addon" ng-bind="item.product.son_unit"></span>
                                                </div>
                                            </div>
                                            <input type="number" name="number[]" class="form-control input-small hide" ng-model="item.number" />
                                        </td>
                                        <td>
                                            <input type="text" class="text input-small hide" name="unit[]" value="{{item.product.mother_to_son}}{{item.product.son_unit}}/{{item.product.mother_unit}}" readonly/>
                                            <input type="text" class="text input-small hide" name="pid[]" value="{{item.product.id}}" readonly/>
                                            <input type="text" class="text input-small hide" name="dpid[]" value="{:I('dpid')}" readonly/>
                                            <input type="text" class="text input-small hide" name="spec[]" value="{{item.product.spec}}" readonly/>
                                            <input type="text" class="text input-small hide" name="unitprice[]" value="{{item.product.unitprice}}" readonly/>
                                            <input type="text" class="form-control input-small"  ng-model="item.totalprice" name="totalprice[]" />
                                        </td>
                                        <td>
                                            <span class="btn btn-primary" ng-click="removeItem($index)">-</span>
                                        </td>
                                    </tr>
                                <!--读取商品信息-->
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
            <div class="col-md-12">
                <button class="btn confirm btn-danger ajax-post" id="submit" type="submit" target-form="form-horizontal" autocomplete="off">申 请</button>
                <a  class="btn btn-primary" id="fh" onclick="javascript:history.back(-1); return false;">返 回</a>
            </div>
        </form>
    </div>
</block>

<block name="script">
    <script src="__JS__/subpro.js"></script>
    <script type="text/javascript">
        //导航高亮
    </script>
</block>
